<html>
<head>
    <meta charset="utf-8"/>
    <title>评价打赏</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name=”apple-mobile-web-app-status-bar-style” content=”default”/>
    <meta name=”apple-mobile-web-app-status-bar-style” content=”black”/>
    <meta name=”apple-mobile-web-app-status-bar-style” content=”black-translucent”/>
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <meta name="format-detection" content="telephone=no"/>
    <link href="${s.base}/mobile/css/weui.min.css" rel="stylesheet"/>
    <link href="${s.base}/mobile/css/jquery-weui.css" rel="stylesheet">
    <link href="${s.base}/mobile/css/weReward.css" rel="stylesheet"/>
</head>
<body>
<div class="tc" style="display: none;">
    <div class="dscg-ctn">
        <div class="dscg-ctn-nei">
            <div class="dscg-pic">
                <img src="${s.base}/mobile/images/hongbao.png">
            </div>
            <span class="cytfonts clsoe" id="close">&#xe659;</span>
        </div>
    </div>
</div>
<div class="ds-list" onclick="window.open('myRewardList?token=${token}&applyId=${applyId}','_self')">打赏记录</div>
<div class="maintop">
    <div class="user-name"><span>姓名：${name}</span><span>工号：${jobNum}</span></div>
    <div class="user-Avatar"><img src="${headLogo}"></div>
</div>
<div class="mainreward clearfix" style="margin-top: 1.9rem;">
    <ul>
        <li value="0">不打赏</li>
        <#if (rewardMoneyVoList??) && (rewardMoneyVoList?size > 0) >
        <#list rewardMoneyVoList as p>
        <#if p_index == 0>
        <li class="checked" value="${p.money}">${p.money}</li>
        <#else>
        <li value="${p.money}">${p.money}</li>
        </#if>
        </#list>
        </#if>
        <li value=""><span>其他金额</span><input type="text" style="display:none;" placeholder="请输入金额"></li>
    </ul>
</div>
<div class="mainreward" id="star">
    <div class="eva-tit">评价一下</div>
    <div class="eva-star">
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
    </div>
</div>
<div class="mainreward" id="eva-list" style=" margin-top:0.4rem;">
    <div class="eva-list">
        <#if (rewardTagVoList??) && (rewardTagVoList?size > 0) >
        <#list rewardTagVoList as p>
        <span>${p.name}</span>
    </#list>
    </#if>
    </div>
</div>
<div class="mainreward" style=" margin-top:0.4rem;" id="text">
    <textarea rows="4" placeholder="亲爱的客户，您对我的服务还满意吗？点击此处输入对我的评价吧~" maxlength="2000"></textarea>
    <button type="button" id="lkds">立刻打赏</button>
</div>
</body>
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script src="${s.base}/mobile/js/fontSize.js" type="text/javascript"></script>
<script src="${s.base}/mobile/js/jquery-2.1.4.min.js" type="text/javascript"></script>
<script src="${s.base}/mobile/js/jquery-weui.js" type="text/javascript"></script>
<script src="${s.base}/mobile/js/common.js" type="text/javascript"></script>
<script src="${s.base}/mobile/js/H5Pay.js" type="text/javascript"></script>
<script>
    window.addEventListener('resize', function() {
        if(
            document.activeElement.tagName === 'input' ||
            document.activeElement.tagName === 'textarea'
        ) {
            window.setTimeout(function() {
                if('scrollIntoView' in document.activeElement) {
                    document.activeElement.scrollIntoView();
                } else {
                    document.activeElement.scrollIntoViewIfNeeded();
                }
            }, 0);
        }
    });
    $(function () {
        $(".mainreward li").bind("click", function () {
            var li = $(".mainreward li");
            var maxLen = li.length;
            li.removeClass("checked");
            $(this).addClass("checked");
            if ($(this).index() === maxLen - 1) {
                $(this).find("span").hide();
                $(this).find("input").show().focus();
            } else {
                $(".mainreward ul li:nth-child(" + maxLen + ") span").show().html("其他金额");
            }
        });

        $(".mainreward input").bind("blur", function () {
            var money = $(this).val();
            if (isBlank(money)) {
                $(this).attr("placeholder", "请输入金额")
            } else {
                if (isNotMoney(money)) {
                    $(this).val('');
                } else {
                    $(this).parent("li").find("span").show();
                    $(this).parent("li").find("span").html(parseFloat(money).toFixed(2));
                    $(this).parent("li").attr('value', parseFloat(money).toFixed(2));
                }
            }
        });

        $("#star").on("click", "span", function () {
            var index = $(this).index();
            $(".eva-star span").each(function () {
                var mindex = $(this).index();
                if (mindex > index) {
                    $(this).removeClass("checked")
                } else {
                    $(this).addClass("checked")
                }
            })
        });

        $("#eva-list").on("click", "span", function () {
            if ($(this).hasClass("checked")) {
                $(this).removeClass("checked");
            } else {
                $(this).addClass("checked");
            }
        });

        $(".mainreward").on("click", "#lkds", function () {
            var params = {};
            params.token = '${token}';
            params.applyId = '${applyId}';
            params.staffId = '${staffId}';
            params.money = $(".mainreward li.checked").attr('value');
            if (isBlank(params.money)) {
                $.toast("请输入金额", "text");
                return false;
            }
            params.stars = $(".eva-star span.checked").length;
            var tagName = [];
            $('.eva-list span.checked').each(function (i, e) {
                tagName.push(e.innerHTML);
            });
            params.tagName = tagName.join("，");
            params.comments = $('.mainreward textarea').val();
            $.fn.doPost('/phone/rewardrecord/addOrUpdate', params, function (result) {
                if (result.code === 0) {
                    if(result.data.payStatus=="3"){
                        //支付成功
                        $(".tc").show();
                    }else{
                     //调用支付
                        pay(result.data.id,'${wxMember.openid}', params.applyId);
                    }
                }
            });
        });

        $(".tc").on("click", "#close", function () {
            $(".tc").hide();
            window.location.reload();
        })

    })

</script>
</html>